#!/bin/bash

# Diawi配置文件
# 包含所有Diawi相关的配置信息

# Diawi API配置
export DIAWI_TOKEN="z1EH0NMJgFBt9wKES8UYny1PlxpVvczVriqrf1Scv6"
export DIAWI_UPLOAD_URL="https://upload.diawi.com/"
export DIAWI_STATUS_URL="https://upload.diawi.com/status"

# 项目配置
export PROJECT_NAME="flutter_ai_base"
export PROJECT_DISPLAY_NAME="Flutter AI Base"

# 构建配置
export ANDROID_BUILD_MODE="release"
export IOS_BUILD_MODE="release"
export ANDROID_TARGET_PLATFORM="android-arm64"

# 文件路径配置
export ANDROID_APK_PATH="build/app/outputs/flutter-apk/app-release.apk"
export IOS_IPA_PATH="build/ios/flutter_ai_base.ipa"
export IOS_APP_PATH="build/ios/iphoneos/Runner.app"

# 上传配置
export DIAWI_WALL_OF_APPS="false"
export DIAWI_PASSWORD=""
export DIAWI_FIND_BY_UDID="true"

# 输出配置
export LINKS_FILE="diawi_links.txt"
export LOG_FILE="diawi_upload.log"

# 获取版本号
get_version() {
    if [ -f "pubspec.yaml" ]; then
        grep "version:" pubspec.yaml | sed 's/version: //' | tr -d ' '
    else
        echo "1.0.0"
    fi
}

# 生成评论
generate_comment() {
    local platform=$1
    local version=$(get_version)
    echo "$platform build - Version: $version - $(date '+%Y-%m-%d %H:%M:%S')"
}

# 检查jq是否安装
has_jq() {
    command -v jq &> /dev/null
}

# 安装jq的提示
install_jq_hint() {
    echo "建议安装jq以获得更好的JSON解析体验："
    if [[ "$OSTYPE" == "darwin"* ]]; then
        echo "  brew install jq"
    elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
        echo "  sudo apt-get install jq  # Ubuntu/Debian"
        echo "  sudo yum install jq      # CentOS/RHEL"
    fi
}

export -f get_version
export -f generate_comment
export -f has_jq
export -f install_jq_hint 